package com.ruowei.modules.sys.utils;

import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.UUID;

public final class ESBUtil {

    public static String genRequest(String msgCd, String body) {
        ZonedDateTime now = ZonedDateTime.now();
        DateTimeFormatter dateDTF = DateTimeFormatter.ofPattern("yyyyMMdd");
        DateTimeFormatter timeDTF = DateTimeFormatter.ofPattern("HHmmssSSS");
        // @formatter:off
        return
            "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" +
                "<transaction>" +
                "<header>" +
                "<ver>1.0</ver>" +
                "<msg>" +
                "<msgCd>" + msgCd + "</msgCd>" +
                "<seqNb>" + UUID.randomUUID().toString().replace("-", "") + "</seqNb>" +
                "<sndAppCd>N6</sndAppCd>" +
                "<sndDt>" + dateDTF.format(now) + "</sndDt>" +
                "<sndTm>" + timeDTF.format(now) + "</sndTm>" +
                "</msg>" +
                "</header>" +
                "<body>" +
                "<request>" + body + "</request>" +
                "</body>" +
                "</transaction>";
        // @formatter:on
    }
}
